<?php
session_start();
//require_once("include/authen.php");

	require_once("class/m_customer_history.php");
	
	$id=$_GET['i'];
	$amt=$_GET['a'];
	$c=$_GET['c'];
	 
	 $id=substr($id,0,-1);
	 $amt=substr($amt,0,-1);
	 $aramt = explode('|',$amt);
	
	$m=new M_customer_history();
	$arr = $m->getPrintData($id,$c);
	 
	 
?>
<table width="320px"cellspacing="0" cellpadding="2" border="0">
 
<tr>
	<td colspan="3">
		<table width="100%">
		<tr>
			<td  width="50%" align='left' style="font-size:11;font-family:tahoma">หมายเลขใบเสร็จ: &nbsp;<?php echo str_repeat('0', 5 - strlen($arr['BillNo']) ) .$arr['BillNo']?></td>
			<td align='right' style="font-size:11;font-family:tahoma">Date:&nbsp;<?php echo $arr['CDate']?></td>
		</tr>
		</table>
	</td>
</tr>

<tr>
	<td colspan="3" align='center' style="font-size:12;font-family:tahoma;font-weight:bold;padding-top:5px">เอกสารเข้าใช้บริการ</td>
</tr>
<tr>
	<td colspan="3" align='center' style="font-size:10">====================================================</td>
</tr>
<tr>
	<td align='left' width="10"  style="font-size:11;font-family:tahoma;padding-left:3px;"> </td>
	<td align='left' width="250" style="font-size:11;font-family:tahoma;padding-left:0px;"> </td>
	<td align='right'   style="font-size:11;font-family:tahoma"> </td>
</tr>
  
<tr>
	<td colspan="3" align='left'  style="line-height:30px;font-size:11;font-family:tahoma;padding-left:2px;;font-weight:normal;"><b>ชื่อลูกค้า :</b> <?php echo $arr['FirstName'] .' '. $arr['LastName'] ?></td>
</tr>
<?php
	$p = $arr['Product'];
	echo $arr['script'];
	$i=0;
	foreach ($p as $var){ 
	
?>	
<tr>
	<td colspan="3" align='left' style="font-size:11;font-family:tahoma;padding-left:2px;;font-weight:normal;"><b>ตัดคอร์ส  </b><?php echo $var['ProductName'] .' :     จำนวน ' . $aramt[$i] .' ครั้ง'  ?></td>
</tr>
<tr>
	<td colspan="3" align='center' >
	<table style='width:100%'>
		<tr>
			<td width='50%' align='left' style="font-size:11;font-family:tahoma;padding-left:2px;;font-weight:normal;"><b>จำนวนคงเหลือ : </b><?php echo $var['Remain'] ?> ครั้ง</td>
			<td align='right' style="font-size:11;font-family:tahoma;padding-left:2px;;font-weight:normal;"><b>หมดอายุ : </b><?php echo $var['ExpireDate'] ?></td>
		</tr>
	</table>
	</td>
</tr>
<?php 
	$i++;
}
?>
<tr>
	<td colspan="3" align='center' style="font-size:10">.....................................................................................................</td>
</tr> 
<?php
	if ($arr['cnts'] > 0 ){
		$detail = $arr['Service'];
		foreach ($detail as $var){
?>
<tr>
	<td colspan="3" align='left' style="font-size:11;font-family:tahoma;padding-left:2px;;font-weight:normal;"><b>คอร์ส : </b><?php echo $var['ProductName'] ?></td>
</tr>
<tr>
	<td colspan="3" align='center' >
	<table style='width:100%'>
		<tr>
			<td width='50%' align='left' style="font-size:11;font-family:tahoma;padding-left:2px;;font-weight:normal;"><b>จำนวนคงเหลือ : </b><?php echo $var['Remain'] ?> ครั้ง</td>
			<td align='right' style="font-size:11;font-family:tahoma;padding-left:2px;;font-weight:normal;"><b>หมดอายุ : </b><?php echo $var['ExpireDate'] ?></td>
		</tr>
	</table>
	</td>
</tr>
 <?php 
 } }
 ?>
<tr>
	<td colspan="3" align='center' style="height:20px;">&nbsp;</td>
</tr>
<tr>
	<td colspan="3" align='center' style="font-size:10;font-family:tahoma;padding-left:2px;;font-weight:normal;color:#333;">**โปรเก็บเอกสารนี้ไว้เป็นหลักฐานการเข้าใช้บริการ</td>
</tr>
</table>
<?php 
 echo "<script>window.print();</script>";
?>